package com.qf.qfcenterservice.api;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.common.bean.R;
import com.qf.common.feigns.GroupApi;
import com.qf.common.model.QfGroup;
import com.qf.qfcenterservice.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GroupFeignApi implements GroupApi {

    @Autowired
    private GroupService groupService;

    @GetMapping("/api/group/listByTenantId")
    public R listByTenantId(@RequestParam("tenantId") Long tenantId){
        IPage<QfGroup> page = new Page<>(1,20);

        Wrapper<QfGroup> qw = Wrappers.lambdaQuery(QfGroup.class)
                .eq(QfGroup::getTenantId,tenantId)
                .eq(QfGroup::getDeleted,0);
        groupService.page(page,qw);

        return R.ok(page);
    }
}
